//
//  CollectCollectionViewCell.m
//  Menu
//
//  Created by YouLu on 15/7/8.
//  Copyright (c) 2015年 lijiangang. All rights reserved.
//

#import "CollectCollectionViewCell.h"

@implementation CollectCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    
    return self;
}
-(void)createSubviews
{
    self.picImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.contentView.frame.origin.x + 5*WIDTH, self.contentView.frame.origin.y + 5*HEIGHT, 150*WIDTH, 90*HEIGHT)];
    [self.contentView addSubview:self.picImageView];
    [_picImageView release];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.contentView.frame.origin.x, self.contentView.frame.origin.y + 90*HEIGHT, 170*WIDTH, 30*HEIGHT)];
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.nameLabel];
    [_nameLabel release];
    
    self.tagImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 120*HEIGHT-15, 15, 15)];
    self.tagImgView.image = [UIImage imageNamed:@"CheckBoxUpSkin@2x.png"];
    self.tagImgView.hidden = YES;
    [self.contentView addSubview:self.tagImgView];
    [_tagImgView release];
    
    self.tagImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 120*HEIGHT-15, 15, 15)];
    self.tagImg.image = [UIImage imageNamed:@"CheckBoxSelectedSkin@2x.png"];
    self.tagImg.hidden = YES;
    [self.contentView addSubview:self.tagImg];
    [_tagImg release];

}
-(void)setCollectModel:(CollectModel *)collectModel
{
    if (_collectModel != collectModel) {
        [_collectModel release];
        _collectModel = [collectModel retain];
        
    }
    if (collectModel.isSelected == NO) {
        self.tagImgView.hidden = YES;
        
    } else {
        self.tagImgView.hidden = NO;
        
    }
    if (collectModel.isEditing == NO) {
        self.tagImg.hidden = YES;
    } else {
        self.tagImg.hidden = NO;
    }
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:self.collectModel.picUrl]];
    self.nameLabel.text = self.collectModel.foodName;
}

@end
